package main

import (
	"IrisStandard/config"
	"IrisStandard/router"
	"IrisStandard/util"
	"github.com/kataras/iris"
	"github.com/kataras/iris/middleware/logger"
	"github.com/kataras/iris/middleware/recover"
)

func main() {
	app := iris.New()
	if config.Setting.Debug {
		app.Logger().SetLevel("debug")
	}
	app.Use(recover.New())
	app.Use(logger.New())

	// 初始化路由
	router.InitRouter(app)

	app.Configure(iris.WithOptimizations)
	app.Configure(iris.WithoutServerError(iris.ErrServerClosed))

	err := app.Run(iris.Addr(config.Setting.Server.Host + ":" + config.Setting.Server.Port))
	util.FailOnException("An error occurred while starting the service", err)
}
